#ifndef SNAKE_HPP_INCLUDED
#define SNAKE_HPP_INCLUDED

#include <list>

#include <SFML/Graphics.hpp>

#include "../game_state.hpp"
#include "../singleton.hpp"

struct Worm {
	Worm() {
		duration = 0;
	}
	
	bool alive;
	int direction;
	std::vector<sf::Sprite> balls;
	
	// computer
	int duration;
};

class Snake: public GameState, public Singleton<Snake> {
	friend class Singleton<Snake>;
	public:
		void init(Engine *engine);
		void cleanup();
		
		void pause();
		void resume();
		
		void processEvent(Engine *engine, PlayerEvent& event);
		void update(Engine *engine);
		void draw(Engine *engine);
		
		bool quit;
		float quitTime;
		float lastTime;
		sf::Clock clock;
		std::map<int, Worm> worms;
		
		std::list<ScoreString> scoreStrings;
		sf::Sprite fruit;
		float fruitTime;
		float gameSpeed;
		int fruitSize;
		
		sf::Sound crunch, dead, start;
		sf::Sprite background;
		
	protected:
		Snake();
		~Snake();
		
		void addScore(Engine *engine, int player, int score);
};

#endif // SNAKE_HPP_INCLUDED
